<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <title>添加点标记</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge">
    <style>
        body,
        html,
        #container {
            overflow: hidden;
            width: 100%;
            height: 100%;
            margin: 0;
            font-family: "微软雅黑";
        }
    </style>
    <script src="//api.map.baidu.com/api?type=webgl&v=1.0&ak=DWXt5d9kvrc80T3LVemDuiPawOHvNkLx"></script>
    <!-- 引入样式 -->
    <link rel="stylesheet" href="../plugins/elementui/index.css">
    <link rel="stylesheet" href="../plugins/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="../css/style.css">

    <script>function on() {
        location.reload();
    }</script>

</head>
<body>

<button type="button" onclick="on()" style="width: 100px;height: 40px;">刷新</button>

<div id="container"></div>
</body>
</html>
<script src="/js/vue.js"></script>
<script src="/js/axios-0.18.0.js"></script>
<script type="text/javascript" src="/js/jquery.min.js"></script>

<script>


    var map = new BMapGL.Map('container');
    map.centerAndZoom(new BMapGL.Point(104.06, 30.67), 12);
    map.enableScrollWheelZoom(true);

    axios.get("/address/findAll.do").then((res) => {
        if (res.data.flag) {
            var list = res.data.data;
            for (address of list) {
                // 创建点标记
                var marker = new BMapGL.Marker(new BMapGL.Point(address.lng, address.lat));
                // 在地图上添加点标记
                map.addOverlay(marker);

                var opts = {
                    position: new BMapGL.Point(address.lng, address.lat), // 指定文本标注所在的地理位置
                    offset: new BMapGL.Size(10, -40) // 设置文本偏移量
                };

                // 创建文本标注对象
                var label = new BMapGL.Label(address.address, opts);
                map.addOverlay(label);
                // 自定义文本标注样式
                label.setStyle({
                    color: 'black',
                    borderRadius: '5px',
                    borderColor: 'red',
                    padding: '10px',
                    fontSize: '16px',
                    height: '30px',
                    lineHeight: '30px',
                    fontFamily: '微软雅黑'
                });
            }
        }
    })
</script>
